package ${classPath}.entity;

<#list imports as import>
import ${import};
</#list>

import org.apache.commons.lang3.StringUtils;

/**
 * ${table.remark}实体类
 *
 *
 * @author ${author}
 * @version ${currentDate} ${author}
 */
public class ${table.className}${entitySuffix} {
	<#list columns as column>
	
	/** ${column.remark} */
    private ${column.javaTypeName} ${column.fieldName};
	</#list>
	<#list columns as column>
	
	/**
     * 设置${column.remark}
     * 
     * @param ${column.fieldName} ${column.remark}
     */
    public void set${column.mothedName}(${column.javaTypeName} ${column.fieldName}) {
        this.${column.fieldName} = ${column.fieldName};
    }

	/**
     * 获取${column.remark}
     * 
     * @return ${column.remark}
     */
    public ${column.javaTypeName} get${column.mothedName}() {
        return ${column.fieldName};
    }
	</#list>
	
	/**
     * 检查字段长度是否超长，检查非空字段是否有值
     * 
     * @return 检查提示信息，为null时表示检查通过
     */
	public String valid(){
		<#list columns as column>
		<#if column.javaTypeName='String'>
		
		if(StringUtils.isNotBlank(${column.fieldName})&&${column.fieldName}.length()>${column.columnSize}){
	        return "${column.remark}值超长，允许输入的最大长度为：${column.columnSize}字符";
		}
		</#if>
		</#list>
		<#list columns as column>
		<#if column.javaTypeName='String' && column.isNullAble='columnNoNulls'>
		
	    if(StringUtils.isBlank(${column.fieldName})){
	        return "${column.remark}不能为空";
		}
		<#elseif column.isNullAble='columnNoNulls'>
	    if(${column.fieldName}==null){
	        return "${column.remark}不能为空";
		}
		</#if>
		</#list>
		
		return null;
	}
}